<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<jsp:directive.page language="java"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" />
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>附件</title>
		<%@ include file="/commons/includes/taglib.jspf"%>
		<%@ include file="/commons/includes/meta.jspf"%>
		<%@ include file="/commons/includes/script.jspf"%>
		<%@ include file="/commons/includes/style.jspf"%>
		<%@ include file="/commons/extremecomponents/extremetable.jspf"%>
	</head>
	<body>
		<form name="attachment"
			action="<c:url value="/commons/attachment/upload.shtml" />"
			method="post" enctype="multipart/form-data">
			<input type="hidden" name="event" value="save" />
			<input type="hidden" name="atchType" value="${form.atchType}" />
			<input type="hidden" name="entityRefId" value="${form.entityRefId}" />
			<div id="divResult" style="display: none;">
				<c:out value="${form.result}" />
			</div>
			<c:if test="${'PHOTO' eq form.atchType}">
				<jsp:useBean id="now" class="java.util.Date" />
				<button class="btn2" id="abtnSave" type="submit" disabled="disabled">
					保 存
				</button>
				<button class="btn2" id="abtnNew">
					新 增
				</button>
				<button class="btn3" id="abtnHide">
					隐藏附件
				</button>
				<button class="btn3" id="abtnBackToTop">
					回到页首
				</button>
				<table id="tbNewPhoto" width="100%" class="editBlock"
					style="display: none;">
					<tr>
						<td class="label" width="15%">
							标&emsp;题
						</td>
						<td width="35%">
							<input type="hidden" name="photo.id" />
							<input type="text" class="text" name="photo.title" />
						</td>
						<td class="label" width="15%">
							序&emsp;号
						</td>
						<td width="35%">
							<input type="text" class="text" maxlength="3" name="photo.order" onkeydown="checkPositiveInteger();" />
						</td>
					</tr>
					<tr>
						<td class="label">
							内&emsp;容
						</td>
						<td colspan="3">
							<textarea rows="3" name="photo.photoContent"></textarea>
						</td>
					</tr>
					<tr>
						<td class="label">
							上传附件
						</td>
						<td colspan="3">
							<input type="file" id="upFiles" name="file" style="ime-mode:disabled;" onkeydown="window.event.returnValue=false;" onpaste="return false;" />
							<div id="divSelectedFiles" style="display: none;">
								待上传附件：
							</div>
						</td>
					</tr>
					<tr>
						<td class="label">
							附件列表
						</td>
						<td colspan="3" id="tdUploaded">
						</td>
					</tr>
				</table>
				<br />
				<table width="100%">
					<tr>
						<td width="60%" align="center" id="primaryPhoto">
							<c:if test="${not empty primaryPhoto}">
								<img style="height: 350px; border: 3px double gray"
									src="<c:url value="/commons/showImg.shtml?id=${primaryPhoto.id}&atchType=${primaryPhoto.type}&now=${now}" />"
									alt="${primaryPhoto.title}" />
							</c:if>
						</td>
						<td width="40%">
							<textarea id="primaryDesc" style="height: 350px;" readonly="readonly"></textarea>
						</td>
					</tr>
				</table>
				<br />
				<table width="100%" class="editBlock" id="uploadedFiles">
					<c:if test="${not empty form.attachments}">
						<tr>
							<td colspan="6">
								页号：
								<c:forEach begin="1" end="${pageCount}" var="page">
									<c:if test="${form.page eq page}">
										<a style="font-weight: bold; color: red;"><c:out
												value="${page}" /> </a>
									</c:if>
									<c:if test="${form.page ne page}">
										<a id="hrefPage" href="javascript: void(0);" page="${page}"><c:out
												value="${page}" /> </a>
									</c:if>
								</c:forEach>
								<input type="hidden" name="page" value="${form.page}" />
							</td>
						</tr>
						<c:forEach var="ind" step="2" begin="0"
							end="${(photoCnts%2==0)?(photoCnts-2):photoCnts}">
							<tr>
								<c:forEach begin="0" end="1" var="i">
									<td colspan="3" width="50%">
										<c:out value="${form.attachments[ind+i].title}" />
									</td>
								</c:forEach>
							</tr>
							<tr>
								<c:forEach begin="0" end="1" var="i">
									<td rowspan="6" width="25%" align="center" valign="middle" id="tdThumb${form.attachments[ind+i].id}">
										<c:if test="${not form.attachments[ind+i].emptyPhoto && ind+i lt photoCnts}">
											<a
												href="<c:url value="/commons/showImg.shtml?id=${form.attachments[ind+i].id}&atchType=${form.attachments[ind+i].type}&now=${now}" />"
												title="<c:out value="${form.attachments[ind+i].title}" />" class="zoomImg"><img
													height="150" style="border: 3px double gray" onload="resizePhoto(this);"
													src="<c:url value="/commons/showThumb.shtml?id=${form.attachments[ind+i].id}&atchType=${form.attachments[ind+i].type}&now=${now}" />"
													alt="${form.attachments[ind+i].title}" /> </a>
										</c:if>
									</td>
									<td width="7%" align="center">
										序&emsp;号
									</td>
									<td width="18%">
										<c:out value="${form.attachments[ind+i].order}" />
									</td>
								</c:forEach>
							</tr>
							<tr>
								<c:forEach begin="0" end="1" var="i">
									<td align="right">
										<c:if test="${ind+i lt photoCnts}">
											<a id="hrefEdit" href="javascript: void(0);">编辑</a>
											<a id="hrefDel" href="javascript: void(0);">删除</a>
											<input type="hidden" id="id" value="${form.attachments[ind+i].id}" />
											<input type="hidden" id="title" value="${form.attachments[ind+i].title}" />
											<input type="hidden" id="order" value="${form.attachments[ind+i].order}" />
											<input type="hidden" id="photoContent" value="${form.attachments[ind+i].photoContent}" />
											<input type="hidden" id="fullname" value="${form.attachments[ind+i].name}${form.attachments[ind+i].extension}" />
											<input type="hidden" id="emptyPhoto" value="${form.attachments[ind+i].emptyPhoto}" />
										</c:if>
									</td>
									<td align="center">
										内&emsp;容
									</td>
									<td>
										<c:out value="${form.attachments[ind+i].photoContent}" />
									</td>
								</c:forEach>
							</tr>
						</c:forEach>
					</c:if>
				</table>
			</c:if>
			<c:if test="${'PHOTO' ne form.atchType}">
				<table width="100%" style="margin-top: 10px;">
					<tr>
						<td colspan="3">
							<button class="btn3" id="abtnHide">
								隐藏附件
							</button>
							<button class="btn3" id="abtnBackToTop">
								回到页首
							</button>
						</td>
					</tr>
					<tr>
						<td width="70">
							上传附件：
						</td>
						<td width="50%">
							<input type="file" id="upFiles" name="file" style="width: 100%; ime-mode:disabled;" onkeydown="window.event.returnValue=false;" onpaste="return false;" />
						</td>
						<td style="padding-left: 5px;">
							<button class="btn2" type="submit">
								上传
							</button>
						</td>
					</tr>
					<tr>
						<td colspan="3" style="padding-top: 5px; padding-bottom: 5px;">
							<div id="divSelectedFiles" style="display: none;">
								待上传附件：
							</div>
						</td>
					</tr>
					<tr>
						<td colspan="3" style="padding-top: 5px; padding-bottom: 5px;"
							id="uploadedFiles">
							<c:if test="${not empty form.attachments}">
					已上传附件：
				</c:if>
							<div>
								<c:forEach var="attachment" items="${form.attachments}">
									<div>
										<img src="<c:url value="/commons/images/icon_trash.gif" />"
											id="imgDelAttachment" attachmentId="${attachment.id}"
											height="16" width="16" alt="删除附件" style="cursor: pointer;" />&nbsp;<a
											href="<c:url value="/commons/download.shtml?id=${attachment.id}" />"
											title="下载 『${attachment.name}${attachment.extension}』"><c:out
												value="${attachment.name}${attachment.extension}" /> </a>
									</div>
								</c:forEach>
							</div>
						</td>
					</tr>
				</table>
			</c:if>
			<button class="btn3" id="abtnBackToTop">
				回到页首
			</button>
		</form>
	</body>
</html>